<template>
    <div id="dashboard">
        仪表盘
        <button v-permission="['admin']">kkk</button>
        <div id="main" style="width:500px;height:500px;"></div>
        <button @click="setLineData">翻转</button>
    </div>
</template>

<script>
import * as echarts from 'echarts';
export default {
    name: 'HelloWorld',
    data() {
        return {
            orgOptions: {},
            lineData: [820, 932, 901, 934, 1290, 1330, 1320],
            myChart: null
        }
    },
    mounted() {
        // 基于准备好的dom，初始化echarts实例
        this.myChart = echarts.init(document.getElementById('main'));
        // 绘制图表
        this.initChart()

    },
    methods: {
        setLineData() {
            this.lineData = this.lineData.reverse()
            this.initChart() // 重新绘制

        },
        initChart() {
            this.myChart.setOption({
                xAxis: {
                    type: 'category',
                    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
                },
                yAxis: {
                    type: 'value'
                },
                series: [
                    {
                        data: this.lineData,
                        type: 'line',
                        smooth: true
                    }
                ]
            });
        }
    }
}
</script>

<style>
</style>